Unfortunately, it is not possible (for me) to generate leaflet objects in RMarkdown (.Rmd), knit the .Rmd file to an markdown file (.md) and an .html document, to them use the .md file as page with GitHub pages. For some reason this is not working and I could not figure out way, yet. However, the generated .html file from RStudio is working, however, the formatting is not the same as for the rest of the site. Sorry for that!
In case anyone can provide some help and hint feel free to drop me a line or post an answer at stackoverflow. Thank you!
Loading the workspace that has been saved in the first part of the data exploration.
# Entire workspace.
source_data("https://github.com/thomassie/Storms/blob/master/Exploration/StormDataWorkSpace.RData?raw=true")
## [1] "plot.pressure.dens.x" "theme_tmm538" "dd.i"
## [4] "plot.pressure.1" "plot.pressure.dens.y" "dd.sum.year"
## [7] "plot.pressure.2" "plot.wind.main" "year.max"
## [10] "topn.WindKPH.Max" "plot.wind.1" "pal_tmm_01"
## [13] "plot.wind.2" "plot.dur" "plot.pres"
## [16] ".Random.seed" "topn.Duration" "plot.pressure.main"
## [19] "topn.Pressure.Min" "w.max" "dd.model.1"
## [22] "model.1" "rho.wind.pres" "n.select"
## [25] "dd" "p.min" "year.min"
## [28] "i" "dd.pacific" "plot.wind"
## [31] "n" "d.max" "plot.wind.dens.x"
## [34] "dd.model.temp.1" "plot.wind.dens.y" "dd.atlantic"
## [37] "dd.sum" "dd.org"
This time I will have a look at specific parts of the data set according to the choices I made before (i.e., a defined time interval; see first part of data exploration).
Let’s have a look at these storms. First, I want to see which are the storms that lasted the longest and where they ocurred. I use a data set called ‘dd.s’ which represents a selection of the entire summary data set ‘dd.sum’.
# renderLeaflet({
# What to show...?
dd.s <- topn.Duration
# Create an indicator for grouping.
groups = as.character(unique(dd.s$KeyPlus))
# The basic map.
map = leaflet(dd.s) %>%
addProviderTiles(providers$CartoDB.DarkMatter)
# Colors of a specific palette assigned to 'Maximum.Wind'.
groupColors = colorNumeric(palette = "YlOrRd", domain = dd$MaxWindKPH)
# Grouping!
for (g in groups) {
d = dd[dd$KeyPlus == g, ]
map = map %>%
addPolylines(data = d,
color = "#788E95",
group = g,
lng = ~ Lon,
lat = ~ Lat,
weight = 0.6,
opacity = 0.6) %>%
addCircleMarkers(data = d,
group = g,
lng = ~Lon,
lat = ~Lat,
color = ~groupColors(WindKPH),
# color = ~groupColors(Saffir.Simpson),
weight = 2,
# fill = FALSE,
radius = ~(WindKPH^1.2)/50,
# radius = ~sqrt(Maximum.Wind)*2,
popup = paste("Name: ", d$Name, "<br>",
"Date: ", date(d$DateTime), "<br>",
"Time: ", strftime(d$DateTime, format="%H:%M:%S",tz = "UTC"), "<br>",
"Status: ", d$Status, "<br>",
"Minimum in central Pressure: ", d$Pressure, "<br>",
"Maximum wind speed: ", d$WindKPH, "km/h"))
}
map %>%
addLayersControl(overlayGroups = groups)